﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Journal.Helpers
{
    /// <summary>
    /// Interaction logic for Calendar.xaml
    /// </summary>
    public partial class CalendarWindow : Window
    {

        private Domain.Calendar calendar;
        private bool canceled = true;

        public CalendarWindow(string title, Domain.Calendar calendar)
        {
            this.calendar = calendar.Clone() as Domain.Calendar;
            this.Title = title;
            InitializeComponent();
            this.textBoxName.Focus();
        }

        private void Window_Initialized(object sender, EventArgs e)
        {
            this.DataContext = this.calendar;
        }

        public Domain.Calendar ShowAndRetrieveCalendar()
        {
            this.ShowDialog();
            if (this.canceled) return null;
            else return this.DataContext as Domain.Calendar;
        }

        private void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            this.canceled = false;
            this.Close();
        }

        private void buttonCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }        

    }
}
